﻿using Microsoft.Extensions.Configuration;

namespace System {
    /// <summary>
    /// 配置帮助类
    /// <code>
    /// //启动的时候赋值
    /// public Startup(IConfiguration configuration) {
    ///     Configuration = configuration;
    ///     ConfigHelper.Configs = Configuration;
    ///  }
    /// 至于调用....var endpoint = ConfigHelper.GetValue("Aliyun:AliyunOssEndPoint");
    /// 或者
    /// string ConnStr = ConfigHelper.Configs["ConnectionStrings:Redis"];
    /// 
    ///  _jwtSetting = _configuration.GetSection("JWTSetting").Get<JwtSetting>();
    /// </code>
    /// </summary>
    public class ConfigHelper {
        public static IConfiguration Configs;
        public static string GetValue(string key) {
            var res = Configs.GetSection(key).Value;
            return res;
        }
        public static T GetValue<T>(string key) {
            var res = Configs.GetSection(key).Get<T>();
            return res;
        }
    }
}
